package br.edu.sistemaacademico.state;

import java.util.LinkedList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComponent;

public class StateHandler implements State{
	public List<JComponent> list = new LinkedList<JComponent>();
	boolean enable = true;
	
	public StateHandler() {}
	
	public StateHandler(boolean enable) {
		this.enable = enable;
	}
	@Override
	public void change() {
		if(enable==true)
			enable = false;
		else
			enable = true;
		
		for(int i=0;i<list.size();i++)
			list.get(i).setEnabled(enable);
	}
	public void addComponent(JComponent component){
		this.list.add(component);
		component.setEnabled(enable);
	}
	
	public void change(boolean enable) {
		this.enable = enable;
		for(int i=0;i<list.size();i++)
			list.get(i).setEnabled(enable);
	}
	public void change(String text, String command, JButton button){
		button.setText(text);
		button.setActionCommand(command);
	}
}
